"""
@author: huangll
@email: ll.huang@hzgosun.com
@time: 2019/6/5 9:32
人口管理的页面元素
"""

from common.poium import Page
from common.vue.float_window import FloatWindow
from common.vue.table import VueTable, VueTurnPage
from common.vue.label import ElementType as ET
from common.vue.label import ElementBaseLabel
from common.vue.search import VueSearch
from common.vue.tree import VueTree
from common.vue.region import VueRegion
from common.vue.button import VueButton
from common.vue.element import VueElements


class SearchTools(VueSearch):
    """查询区域"""
    keyword_dropdown_list = ElementBaseLabel(ET.DROPDOWN_LIST, label="关键字")  # 关键字后面的下拉选框
    keyword_input = ElementBaseLabel(ET.INPUT, label="关键字")  # 关键字后面的输入框
    tag_dropdown_list = ElementBaseLabel(ET.DROPDOWN_LIST, label="标签")
    region_dropdown_list = ElementBaseLabel(ET.DROPDOWN_LIST, label="区域")  # 区域后面的下拉选框
    region_region_input = ElementBaseLabel(ET.REGION, label="区域")  # 区域后面的区域请选择框
    region_grid_input = ElementBaseLabel(ET.GRID, label="区域")  # 区域后面的网格请选择框
    region_region_selector = VueRegion(index=0)  # region_dropdown_list选择区域时，点击region_input出现的
    region_grid_selector = VueTree(index=0, describe="查询区域的网格选择树")  # region_dropdown_list选择网格时，点击region_input出现的
    community_dropdown_list = ElementBaseLabel(ET.DROPDOWN_LIST, label="小区选择")   # 小区请选择框

    search_btn = VueButton("检索")   # 查询按钮
    reset_btn = VueButton("重置")

    def __init__(self):
        super(SearchTools, self).__init__()

        
class Table(VueTable):
    """人口表"""
    add_btn = VueButton("添加")
    add_files_btn = VueButton("导入")

    def __init__(self):
        super(Table, self).__init__()


class AddPersonWindow(FloatWindow):
    """添加人口信息弹窗"""
    base_info = VueElements(tag='li', text="基本信息")
    name = ElementBaseLabel(ET.INPUT, label="姓名")
    gender = ElementBaseLabel(ET.DROPDOWN_LIST, label="性别")
    id_ = ElementBaseLabel(ET.INPUT, label="身份证")
    region = ElementBaseLabel(ET.REGION, label="区域")
    # 这里region_selector会有bug，如果查询区域展开了1个以上，不刷新网页前提下，这里的index不能确定，需要加个visiable的判断
    # 另外，添加人口这里区域选择器是4级的，但一般用3级，默认level就行
    region_selector = VueRegion(index=1)
    grid = ElementBaseLabel(ET.GRID, label="网格")
    grid_selector = VueTree(index=1)
    date = ElementBaseLabel(ET.DATE_PICKER, label="出生日期")
    face_pic = ElementBaseLabel(ET.UPLOAD, label="人脸照", clear_btn_xoffset=60, clear_btn_yoffset=30)

    flag_info = VueElements(tag='li', text="标识信息")
    imsi = ElementBaseLabel(ET.INPUT, label='IMSI')
    add_imsi_btn = VueButton("添加")

    flag_person_tag = VueElements(tag='li', text="人物信息")
    person_imei = ElementBaseLabel(ET.INPUT,label = '手环IMEI')
    guardian_name = ElementBaseLabel(ET.INPUT,label='监护人姓名')
    guardian_phont = ElementBaseLabel(ET.INPUT,label='监护人联系方式')
    village_cadre_name = ElementBaseLabel(ET.INPUT,label='村干部姓名')
    village_cadre_phone = ElementBaseLabel(ET.INPUT,label='村干部联系方式')

    def __init__(self, title=None, index=None):
        super(AddPersonWindow, self).__init__(title=title, index=index)


class ModiyPersonWindow(AddPersonWindow):
    """修改人口信息弹窗"""
    def __init__(self, title=None, index=None):
        super(ModiyPersonWindow, self).__init__(title=title, index=index)


class DeletePersonWindow(AddPersonWindow):
    """删除人员信息弹窗"""
    def __init__(self, title=None, index=None):
        super(DeletePersonWindow, self).__init__(title=title, index=index)


class FilesPersonWindow(AddPersonWindow):
    """导入人员信息弹出"""
    daoru = ElementBaseLabel(ET.UPLOAD, label='请选择EXCEL文档')

    def __init__(self, title=None, index=None):
        super(FilesPersonWindow, self).__init__(title=title, index=index)


class PersonListPage(Page):
    """人口管理页面"""
    searchTools = SearchTools()   # 查询区域
    table = Table()   # 列表
    turnPage = VueTurnPage()   # 翻页
    addPerson = AddPersonWindow(index=1)   # 添加人口弹窗
    modifyPerson = ModiyPersonWindow(index=1)   # 修改人口弹窗
    deletePerson = DeletePersonWindow(title="删除确认")  #删除弹窗
    filesPerson = FilesPersonWindow(title="导入")  #导入按钮点击